package com.dev;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.EditText;
public class UnderlineSingleLineEditor extends EditText{
    public UnderlineSingleLineEditor(MainActivity ma){
		super(ma);
		setBackgroundColor(0x00ffffff);
		setTypeface(Typeface.MONOSPACE);
		setTextSize(TypedValue.COMPLEX_UNIT_DIP,13);
		setGravity(Gravity.CENTER_VERTICAL);
		setTextColor(0xff000000);
		setSingleLine();
	}
    @Override 
	public void onDraw(Canvas cvs){
		super.onDraw(cvs);
		int pl=getPaddingLeft();
		int pr=getPaddingRight();
		int vw=getWidth();
		Paint p=new Paint();
		p.setStrokeWidth(3);
		if(isFocused()){
			p.setColor(0xffff0000);
		}else{
			p.setColor(0xff777777);
		}
		int ver=getHeight()/2+(int)(getTextSize()*0.7);
		cvs.translate(getScrollX(),getScrollY());
		cvs.drawLine(getPaddingLeft(),ver,vw-getPaddingRight(),ver,p);
	}
}
